cmp.ready(function() {
    cmp.dialog.loading();
    var qrCodeId = _getQueryString("M3QRCode");
    var thirdSessionId = _getQueryString("thirdSessionId");
    thirdSessionId = thirdSessionId != undefined ? thirdSessionId : '';
    window.localStorage.setItem("thirdSessionId", thirdSessionId);
    var mpToken = _getQueryString("mpToken");
    mpToken = mpToken != undefined ? mpToken : '';
    window.localStorage.setItem("mpToken", mpToken);
    $s.PublicQrCode.getH5Url(qrCodeId, "", {
        repeat : true, // 当网络掉线时是否自动重新连接
        success : function(result) {
            cmp.dialog.loading(false);
            if (result && result.success) {
                var category = result.data.category;
                var h5Url = result.data.h5Url;
                cmp.href.next(categoryH5Url[category] + h5Url);
            } else {
                cmp.notification.alert(result.msg, function() {
                    cmp.href.closePage();
                });
            }
        },
        error : function(error) {
            cmp.dialog.loading(false);
            var cmpHandled = cmp.errorHandler(error);
            if (cmpHandled) {
                // cmp处理了这个错误
            } else {
                // customHandle(error) ;//走自己的处理错误的逻辑
                cmp.href.closePage();
            }
        }
    });
});

// 解析url方法
function _getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null)
        return unescape(r[2]);
    return null;
}